import type { RouteMeta, RouteRecordRaw } from 'vue-router'

export function buildMeta(data: RouteMeta = {}): RouteMeta {
  return {
    ...data,
    module: 'DEV_OPS_MONITOR',
  }
}

export default {
  path: '/dev-ops-monitor',
  meta: buildMeta(),
  component: () => import('@/components/layout/DefaultLayout.vue'),
  children: [
    {
      path: '',
      meta: buildMeta({ title: '运维监控' }),
      children: [
        {
          path: 'instance-data',
          name: 'DevOpsMonitorInstanceData',
          component: () =>
            import(
              '@/views/dev-ops-monitor/instance-data/InstanceDataView.vue'
            ),
          meta: buildMeta({ title: '实例数据' }),
        },
        {
          path: 'task-monitor',
          children: [
            {
              path: '',
              name: 'DevOpsMonitorTaskMonitor',
              component: () => import('@/views/dev-ops-monitor/task-monitor'),
              meta: buildMeta({ title: '任务监控' }),
            },
            {
              path: ':id',
              name: 'DevOpsMonitorTaskDetails',
              component: () =>
                import(
                  '@/views/dev-ops-monitor/task-monitor/details/TaskDetails.vue'
                ),
              meta: buildMeta({
                title: '任务详情',
                activeMenu: 'DevOpsMonitorTaskMonitor',
                breadcrumbs: [
                  { title: '任务监控', to: '/dev-ops-monitor/task-monitor' },
                ],
              }),
            },
          ],
        },
        {
          path: 'alarm-record',
          name: 'DevOpsMonitorAlarmRecord',
          component: () => import('@/views/dev-ops-monitor/alarm-record'),
          meta: buildMeta({ title: '告警记录' }),
        },
        {
          path: 'alarm-config/:module?',
          name: 'DevOpsMonitorAlarmConfig',
          component: () => import('@/views/dev-ops-monitor/alarm-config'),
          meta: buildMeta({
            title: '告警配置',
            tabs: [
              { title: '接收方式', key: 'method' },
              { title: '告警指标', key: 'indicators' },
            ],
          }),
        },
      ],
    },
  ],
} satisfies RouteRecordRaw
